package com.beaven.model.data.message;

import com.beaven.model.data.DataSource;
import com.beaven.model.model.db.Message;
import java.util.List;
import timber.log.Timber;

/**
 * author: Beaven
 * time: 2017/6/1 10:43
 */

public abstract class MessagePresenter implements DataSource.SuccessCallBack<List<Message>> {

  private MessageRepository repository;

  public MessagePresenter(String receiverId, boolean isGroup) {
    repository = new MessageRepository(receiverId, isGroup);
  }

  public void loadRepo() {
    repository.load(this);
  }

  public void destroy() {
    repository.dispose();
  }

  @Override public void notifyData() {
    repository.load(this);
  }

  @Override public void loadDataSuccess(List<Message> messages) {
    Timber.i("----消息数据库更新---");
    loadData(messages);
  }

  public abstract void loadData(List<Message> messages);
}
